//
// UMaterial.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;

public class UMaterial {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public UMaterial(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(UMaterial obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_UMaterial(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setTexture(long stage, UTexture ptex) {
    nel3dJNI.UMaterial_setTexture__SWIG_0(swigCPtr, this, stage, UTexture.getCPtr(ptex), ptex);
  }

  public boolean texturePresent(long stage) {
    return nel3dJNI.UMaterial_texturePresent__SWIG_0(swigCPtr, this, stage);
  }

  public void selectTextureSet(long id) {
    nel3dJNI.UMaterial_selectTextureSet(swigCPtr, this, id);
  }

  public void setTexture(UTexture ptex) {
    nel3dJNI.UMaterial_setTexture__SWIG_1(swigCPtr, this, UTexture.getCPtr(ptex), ptex);
  }

  public boolean texturePresent() {
    return nel3dJNI.UMaterial_texturePresent__SWIG_1(swigCPtr, this);
  }

  public void setBlend(boolean active) {
    nel3dJNI.UMaterial_setBlend(swigCPtr, this, active);
  }

  public void setBlendFunc(UMaterial.TBlend src, UMaterial.TBlend dst) {
    nel3dJNI.UMaterial_setBlendFunc(swigCPtr, this, src.swigValue(), dst.swigValue());
  }

  public void setSrcBlend(UMaterial.TBlend val) {
    nel3dJNI.UMaterial_setSrcBlend(swigCPtr, this, val.swigValue());
  }

  public void setDstBlend(UMaterial.TBlend val) {
    nel3dJNI.UMaterial_setDstBlend(swigCPtr, this, val.swigValue());
  }

  public boolean getBlend() {
    return nel3dJNI.UMaterial_getBlend(swigCPtr, this);
  }

  public UMaterial.TBlend getSrcBlend() {
    return UMaterial.TBlend.swigToEnum(nel3dJNI.UMaterial_getSrcBlend(swigCPtr, this));
  }

  public UMaterial.TBlend getDstBlend() {
    return UMaterial.TBlend.swigToEnum(nel3dJNI.UMaterial_getDstBlend(swigCPtr, this));
  }

  public void texEnvOpRGB(long stage, UMaterial.TTexOperator ope) {
    nel3dJNI.UMaterial_texEnvOpRGB(swigCPtr, this, stage, ope.swigValue());
  }

  public void texEnvArg0RGB(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg0RGB(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void texEnvArg1RGB(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg1RGB(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void texEnvArg2RGB(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg2RGB(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void texEnvOpAlpha(long stage, UMaterial.TTexOperator ope) {
    nel3dJNI.UMaterial_texEnvOpAlpha(swigCPtr, this, stage, ope.swigValue());
  }

  public void texEnvArg0Alpha(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg0Alpha(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void texEnvArg1Alpha(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg1Alpha(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void texEnvArg2Alpha(long stage, UMaterial.TTexSource src, UMaterial.TTexOperand oper) {
    nel3dJNI.UMaterial_texEnvArg2Alpha(swigCPtr, this, stage, src.swigValue(), oper.swigValue());
  }

  public void setZFunc(UMaterial.ZFunc val) {
    nel3dJNI.UMaterial_setZFunc(swigCPtr, this, val.swigValue());
  }

  public void setZWrite(boolean active) {
    nel3dJNI.UMaterial_setZWrite(swigCPtr, this, active);
  }

  public void setZBias(float val) {
    nel3dJNI.UMaterial_setZBias(swigCPtr, this, val);
  }

  public UMaterial.ZFunc getZFunc() {
    return UMaterial.ZFunc.swigToEnum(nel3dJNI.UMaterial_getZFunc(swigCPtr, this));
  }

  public boolean getZWrite() {
    return nel3dJNI.UMaterial_getZWrite(swigCPtr, this);
  }

  public float getZBias() {
    return nel3dJNI.UMaterial_getZBias(swigCPtr, this);
  }

  public void setAlphaTest(boolean active) {
    nel3dJNI.UMaterial_setAlphaTest(swigCPtr, this, active);
  }

  public boolean getAlphaTest() {
    return nel3dJNI.UMaterial_getAlphaTest(swigCPtr, this);
  }

  public void setAlphaTestThreshold(float threshold) {
    nel3dJNI.UMaterial_setAlphaTestThreshold(swigCPtr, this, threshold);
  }

  public float getAlphaTestThreshold() {
    return nel3dJNI.UMaterial_getAlphaTestThreshold(swigCPtr, this);
  }

  public void setColor(CRGBA rgba) {
    nel3dJNI.UMaterial_setColor(swigCPtr, this, CRGBA.getCPtr(rgba), rgba);
  }

  public CRGBA getColor() {
    return new CRGBA(nel3dJNI.UMaterial_getColor(swigCPtr, this), true);
  }

  public boolean isLighted() {
    return nel3dJNI.UMaterial_isLighted(swigCPtr, this);
  }

  public CRGBA getEmissive() {
    return new CRGBA(nel3dJNI.UMaterial_getEmissive(swigCPtr, this), true);
  }

  public CRGBA getAmbient() {
    return new CRGBA(nel3dJNI.UMaterial_getAmbient(swigCPtr, this), true);
  }

  public CRGBA getDiffuse() {
    return new CRGBA(nel3dJNI.UMaterial_getDiffuse(swigCPtr, this), true);
  }

  public short getOpacity() {
    return nel3dJNI.UMaterial_getOpacity(swigCPtr, this);
  }

  public CRGBA getSpecular() {
    return new CRGBA(nel3dJNI.UMaterial_getSpecular(swigCPtr, this), true);
  }

  public float getShininess() {
    return nel3dJNI.UMaterial_getShininess(swigCPtr, this);
  }

  public void setDoubleSided(boolean doubleSided) {
    nel3dJNI.UMaterial_setDoubleSided__SWIG_0(swigCPtr, this, doubleSided);
  }

  public void setDoubleSided() {
    nel3dJNI.UMaterial_setDoubleSided__SWIG_1(swigCPtr, this);
  }

  public boolean getDoubleSided() {
    return nel3dJNI.UMaterial_getDoubleSided(swigCPtr, this);
  }

  public void initUnlit() {
    nel3dJNI.UMaterial_initUnlit(swigCPtr, this);
  }

  public boolean isSupportedByDriver(UDriver drv, boolean forceBaseCaps) {
    return nel3dJNI.UMaterial_isSupportedByDriver__SWIG_0(swigCPtr, this, UDriver.getCPtr(drv), drv, forceBaseCaps);
  }

  public boolean isSupportedByDriver(UDriver drv) {
    return nel3dJNI.UMaterial_isSupportedByDriver__SWIG_1(swigCPtr, this, UDriver.getCPtr(drv), drv);
  }

  public UMaterial() {
    this(nel3dJNI.new_UMaterial__SWIG_0(), true);
  }

  public UMaterial(CMaterial object) {
    this(nel3dJNI.new_UMaterial__SWIG_1(CMaterial.getCPtr(object), object), true);
  }

  public void attach(CMaterial object) {
    nel3dJNI.UMaterial_attach(swigCPtr, this, CMaterial.getCPtr(object), object);
  }

  public void detach() {
    nel3dJNI.UMaterial_detach(swigCPtr, this);
  }

  public boolean empty() {
    return nel3dJNI.UMaterial_empty(swigCPtr, this);
  }

  public CMaterial getObjectPtr() {
    long cPtr = nel3dJNI.UMaterial_getObjectPtr(swigCPtr, this);
    return (cPtr == 0) ? null : new CMaterial(cPtr, false);
  }

  public final static class ZFunc {
    public final static ZFunc always = new ZFunc("always", nel3dJNI.UMaterial_always_get());
    public final static ZFunc never = new ZFunc("never");
    public final static ZFunc equal = new ZFunc("equal");
    public final static ZFunc notequal = new ZFunc("notequal");
    public final static ZFunc less = new ZFunc("less");
    public final static ZFunc lessequal = new ZFunc("lessequal");
    public final static ZFunc greater = new ZFunc("greater");
    public final static ZFunc greaterequal = new ZFunc("greaterequal");
    public final static ZFunc zfuncCount = new ZFunc("zfuncCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static ZFunc swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + ZFunc.class + " with value " + swigValue);
    }

    private ZFunc(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private ZFunc(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private ZFunc(String swigName, ZFunc swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static ZFunc[] swigValues = { always, never, equal, notequal, less, lessequal, greater, greaterequal, zfuncCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TBlend {
    public final static TBlend one = new TBlend("one", nel3dJNI.UMaterial_one_get());
    public final static TBlend zero = new TBlend("zero");
    public final static TBlend srcalpha = new TBlend("srcalpha");
    public final static TBlend invsrcalpha = new TBlend("invsrcalpha");
    public final static TBlend srccolor = new TBlend("srccolor");
    public final static TBlend invsrccolor = new TBlend("invsrccolor");
    public final static TBlend blendCount = new TBlend("blendCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TBlend swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TBlend.class + " with value " + swigValue);
    }

    private TBlend(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TBlend(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TBlend(String swigName, TBlend swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TBlend[] swigValues = { one, zero, srcalpha, invsrcalpha, srccolor, invsrccolor, blendCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TTexOperator {
    public final static TTexOperator Replace = new TTexOperator("Replace", nel3dJNI.UMaterial_Replace_get());
    public final static TTexOperator Modulate = new TTexOperator("Modulate");
    public final static TTexOperator Add = new TTexOperator("Add");
    public final static TTexOperator AddSigned = new TTexOperator("AddSigned");
    public final static TTexOperator InterpolateTexture = new TTexOperator("InterpolateTexture");
    public final static TTexOperator InterpolatePrevious = new TTexOperator("InterpolatePrevious");
    public final static TTexOperator InterpolateDiffuse = new TTexOperator("InterpolateDiffuse");
    public final static TTexOperator InterpolateConstant = new TTexOperator("InterpolateConstant");
    public final static TTexOperator EMBM = new TTexOperator("EMBM");
    public final static TTexOperator Mad = new TTexOperator("Mad");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TTexOperator swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TTexOperator.class + " with value " + swigValue);
    }

    private TTexOperator(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TTexOperator(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TTexOperator(String swigName, TTexOperator swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TTexOperator[] swigValues = { Replace, Modulate, Add, AddSigned, InterpolateTexture, InterpolatePrevious, InterpolateDiffuse, InterpolateConstant, EMBM, Mad };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TTexSource {
    public final static TTexSource Texture = new TTexSource("Texture", nel3dJNI.UMaterial_Texture_get());
    public final static TTexSource Previous = new TTexSource("Previous");
    public final static TTexSource Diffuse = new TTexSource("Diffuse");
    public final static TTexSource Constant = new TTexSource("Constant");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TTexSource swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TTexSource.class + " with value " + swigValue);
    }

    private TTexSource(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TTexSource(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TTexSource(String swigName, TTexSource swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TTexSource[] swigValues = { Texture, Previous, Diffuse, Constant };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TTexOperand {
    public final static TTexOperand SrcColor = new TTexOperand("SrcColor", nel3dJNI.UMaterial_SrcColor_get());
    public final static TTexOperand InvSrcColor = new TTexOperand("InvSrcColor");
    public final static TTexOperand SrcAlpha = new TTexOperand("SrcAlpha");
    public final static TTexOperand InvSrcAlpha = new TTexOperand("InvSrcAlpha");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TTexOperand swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TTexOperand.class + " with value " + swigValue);
    }

    private TTexOperand(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TTexOperand(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TTexOperand(String swigName, TTexOperand swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TTexOperand[] swigValues = { SrcColor, InvSrcColor, SrcAlpha, InvSrcAlpha };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
